﻿using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp.Study.Deposit
{
    public class DemoBgService : BackgroundService
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var cts = new CancellationTokenSource();
            cts.CancelAfter(TimeSpan.FromSeconds(30));
            while (!cts.IsCancellationRequested)
            {
                await Task.Delay(1000);
                string s = await File.ReadAllTextAsync("e:/km.txt");
                Console.WriteLine(s);
                await Task.Delay(2000);
            }
        }
    }
}
